#ifndef __LCD_INIT_H
#define __LCD_INIT_H

#include "at32f435_437_board.h"

#define USE_HORIZONTAL 0

#define LCD_W 240
#define LCD_H 240

#define LCD_RES_Clr()  gpio_bits_reset(LCD_RST_GPIO,LCD_RST_PIN)//RES
#define LCD_RES_Set()  gpio_bits_set(LCD_RST_GPIO,LCD_RST_PIN)

#define LCD_DC_Clr()   gpio_bits_reset(LCD_DC_GPIO,LCD_DC_PIN)//DC
#define LCD_DC_Set()   gpio_bits_set(LCD_DC_GPIO,LCD_DC_PIN)
 		     
#define LCD_CS_Clr()   gpio_bits_reset(LCD_CS_GPIO,LCD_CS_PIN)//CS
#define LCD_CS_Set()   gpio_bits_set(LCD_CS_GPIO,LCD_CS_PIN)

#define LCD_BLK_Clr()  gpio_bits_reset(LCD_BLK_GPIO,LCD_BLK_PIN)//BLK
#define LCD_BLK_Set()  gpio_bits_set(LCD_BLK_GPIO,LCD_BLK_PIN)

#define LCD_CS_GPIO_CRM_CLK			CRM_GPIOC_PERIPH_CLOCK
#define LCD_CS_PIN							GPIO_PINS_13
#define LCD_CS_GPIO							GPIOC

#define LCD_DC_GPIO_CRM_CLK			CRM_GPIOA_PERIPH_CLOCK
#define LCD_DC_PIN							GPIO_PINS_5
#define LCD_DC_GPIO							GPIOA

#define LCD_BLK_GPIO_CRM_CLK		CRM_GPIOB_PERIPH_CLOCK
#define LCD_BLK_PIN							GPIO_PINS_7
#define LCD_BLK_GPIO						GPIOB

#define LCD_RST_GPIO_CRM_CLK		CRM_GPIOB_PERIPH_CLOCK
#define LCD_RST_PIN							GPIO_PINS_6
#define LCD_RST_GPIO						GPIOB

#define LCD_CLK_GPIO_CRM_CLK		CRM_GPIOB_PERIPH_CLOCK
#define LCD_CLK_PIN							GPIO_PINS_3
#define LCD_CLK_GPIO						GPIOB
#define LCD_CLK_SOURCE					GPIO_PINS_SOURCE3
#define LCD_CLK_MUX							GPIO_MUX_5

#define LCD_DAT_GPIO_CRM_CLK		CRM_GPIOB_PERIPH_CLOCK
#define LCD_DAT_PIN							GPIO_PINS_5
#define LCD_DAT_GPIO						GPIOB
#define LCD_DAT_SOURCE					GPIO_PINS_SOURCE5
#define LCD_DAT_MUX							GPIO_MUX_5

void lcd_gpio_init(void);
void lcd_spi_config(void);
void LCD_WR_DATA8(u8 dat);
void LCD_WR_DATA(u16 dat);
void LCD_WR_REG(u8 dat);
void LCD_Address_Set(u16 x1, u16 y1, u16 x2, u16 y2);
void LCD_Init(void);

#endif